package Demo2;


class singleton{
    private static singleton instance=new singleton();

    private singleton() {
    }

    public static singleton getInstance(){
        return instance;
    }
}


class singleton2{
    private static singleton2 instance;

    static {
        instance=new singleton2();
    }

    public singleton2 getInstance(){
        return instance;
    }
    private singleton2() {
    }
}

public class Demo22 {
    public static void main(String[] args) {
        singleton s1=singleton.getInstance();
        singleton s2=singleton.getInstance();
        System.out.println(s1==s2);
    }
}
